import { createApp, FunctionalComponent } from "vue";
import router from "./routes";
import App from "./App.vue";
import store from "./store";
import "reset-css";
import "element-plus/dist/index.css";
import ElementPlus from "element-plus";
import zhCn from "element-plus/es/locale/lang/zh-cn";
let app = createApp(App);
// app.config.globalProperties.
// for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
//   app.component(key, component as FunctionalComponent<any, any>);
// }
//use方法本质上是调用参数上的install方法，或者如果或参数是函数，就直接调用(详细看vue官网)
//使用use注册路由

//全局注册自定义指令
app.directive("permission", {
  mounted(el, binding) {
    // console.log(binding);
    //modifiers里面是修饰符，可以自定义修饰符做对应操作

    //不存在权限就隐藏按钮
    if (!store.getters.PermissionMenus.includes(binding.value)) el.remove();
  },
});
app.use(router);
app.use(store);
app.use(ElementPlus, {
  locale: zhCn,
});
//一定要注册完最后再挂载
app.mount("#app");
